package com.ruoyi.pointsystem.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pointsystem.domain.Xy01;
import com.ruoyi.pointsystem.service.IXy01Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 新亚01Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@Controller
@RequestMapping("/pointsystem/xy01")
public class Xy01Controller extends BaseController
{
    private String prefix = "pointsystem/xy01";

    @Autowired
    private IXy01Service xy01Service;

    @RequiresPermissions("pointsystem:xy01:view")
    @GetMapping()
    public String xy01()
    {
        return prefix + "/xy01";
    }

    /**
     * 查询新亚01列表
     */
    @RequiresPermissions("pointsystem:xy01:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Xy01 xy01)
    {
        startPage();
        List<Xy01> list = xy01Service.selectXy01List(xy01);
        return getDataTable(list);
    }

    /**
     * 导出新亚01列表
     */
    @RequiresPermissions("pointsystem:xy01:export")
    @Log(title = "新亚01", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Xy01 xy01)
    {
        List<Xy01> list = xy01Service.selectXy01List(xy01);
        ExcelUtil<Xy01> util = new ExcelUtil<Xy01>(Xy01.class);
        return util.exportExcel(list, "新亚01数据");
    }

    /**
     * 新增新亚01
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存新亚01
     */
    @RequiresPermissions("pointsystem:xy01:add")
    @Log(title = "新亚01", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Xy01 xy01)
    {
        return toAjax(xy01Service.insertXy01(xy01));
    }

    /**
     * 修改新亚01
     */
    @RequiresPermissions("pointsystem:xy01:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Xy01 xy01 = xy01Service.selectXy01ById(id);
        mmap.put("xy01", xy01);
        return prefix + "/edit";
    }

    /**
     * 修改保存新亚01
     */
    @RequiresPermissions("pointsystem:xy01:edit")
    @Log(title = "新亚01", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Xy01 xy01)
    {
        return toAjax(xy01Service.updateXy01(xy01));
    }

    /**
     * 删除新亚01
     */
    @RequiresPermissions("pointsystem:xy01:remove")
    @Log(title = "新亚01", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(xy01Service.deleteXy01ByIds(ids));
    }
}
